<?php defined('IN_LK') or die('Access Denied');
lk::lo_app('admin_common', 'admin', 0);
class category extends admin_common
{
	private $db;
	
	public function __construct()
	{
		parent::__construct();
		$this->db = lk::load_model('category');
	}
	
	public function initialize()
	{
		//$tree = lk::lo('tree');
		//$tree->input_arr = $categorys;
		//dump($tree->get_tree(0, 'catname'));
		$categorys = $this->get();
		include self::admin_t('category_list');
	}
	
	/**
	 * 刷新缓存
	 */
	private function update_cache()
	{
		$categorys = $this->db->listinfo('*', '', 1, 100, '`listorder`,`catid` ASC', '', 'catid');
		return set_cache('categorys', $categorys);
	}
	
	/**
	 * 读取缓存
	 */
	private function get()
	{
		$categorys = get_cache('categorys');
		if(!$categorys)
		{
			$this->update_cache();
			$categorys = get_cache('categorys');
		}
		return $categorys;
	}
}